package cn.zzuli.listviewsuper;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ListView;

import java.util.Arrays;

import cn.zzuli.listviewsuper.adapter.CommonAdapter;
import cn.zzuli.listviewsuper.adapter.ViewHolder;

public class MainActivity extends AppCompatActivity {
    private String[] cities={"郑州","开封","洛阳","平顶山","安阳","新乡"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ListView listView=findViewById(R.id.lv_demo);
        CommonAdapter<String> adapter=new CommonAdapter<String>(this, Arrays.asList(cities),R.layout.item_list) {
            @Override
            public void convert(ViewHolder helper, String item) {
                helper.setText(R.id.textView,item);
            }
        };
        listView.setAdapter(adapter);
    }
}